<?php


namespace app\common\model;


use think\Model;

class Goodsredpacketgetlog extends Model
{
            public $table='goods_redpacket_getlog';


    public function getloglist($condition, $field = '*', $page = 0, $order = 'log.used_status desc, log.get_time desc') {
        if($page) {

            $res= db('goods_redpacket_getlog')->alias('log')
                ->join('goods_redpacket red', 'log.goods_redpacket_id=red.id', 'LEFT')
                ->join('goods g', 'g.goods_id=log.goods_id', 'LEFT')
                ->join('member m', 'm.member_id=log.buyer_id', 'LEFT')

                ->where($condition)->field($field)->order($order)->paginate($page,false,['query' => request()->param()]);
            $this->page_info=$res;
            return $res->items();
        }else{
            return db('goods_redpacket_getlog')->alias('log')
                ->join('ds_goods_redpacket red', 'log.goods_redpacket_id=red.id', 'LEFT')->where($condition)->field($field)->order($order)->select();
        }
    }

    public function getOneJoinWxkeyword($condition, $field = '', $order = 't.createtime DESC') {
        $condition['k.type'] = 'TEXT';
        $lists = db('wxkeyword')->alias('k')->join('__WXTEXT__ t', 't.id=k.pid', 'LEFT')->where($condition)->field($field)->order($order)->find();
        return $lists;
    }






}